<template>
    <section class="smartResourceManageDetail">
  			<div class="base_info">
  				<p class="title">基本信息</p>
  				<div class="base_item">
	  				<el-row>
					  <el-col :span="12">
					  	<el-col class="base_title" :span="8">区域名称</el-col>
					  	<el-col class="base_value" :span="16">{{smAreaVo.name}}</el-col>
					  </el-col>
					  <el-col :span="12">
					  	<el-col class="base_title" :span="8">所属网段</el-col>
					  	<el-col class="base_value" :span="16">{{smAreaVo.segmentName}}</el-col>
					  </el-col>
					</el-row>
				</div>
				
				<div class="base_item">
					<el-row>
					  <el-col :span="12">
					  	<el-col class="base_title" :span="8">区域标识</el-col>
					  	<el-col class="base_value" :span="16">{{smAreaVo.nodeSn}}</el-col>
					  </el-col>
					  <el-col :span="12">
					  	<el-col class="base_title" :span="8">连通情况</el-col>
					  	<el-col class="base_value" :span="16">{{smAreaVo.status==1?'正常':'异常'}}</el-col>
					  </el-col>
					</el-row>
				</div>
				
				<div class="base_item">
					<el-row>
					  <el-col :span="4">
					  	<span class="base_title"></span><span class="base_title">内存总量</span>
					  </el-col>
					   <el-col :span="20">
					  	<el-progress 
							:text-inside="true" 
							:stroke-width="18" 
							:percentage="Number(Math.round(smAreaVo.memoryUsage / smAreaVo.memory * 10000)/100.00)"
							 color="#2675c5">
						</el-progress>
						 <span class="base_line">{{smAreaVo.memory}}GB</span>
					  </el-col>
					</el-row>
				</div>
				
				<div class="base_item">
					<el-row>
					  <el-col :span="4">
					  	<span class="base_title"></span><span class="base_title">磁盘大小</span>
					  </el-col>
					   <el-col :span="20">
					  	<el-progress 
							:text-inside="true" 
							:stroke-width="18" 
							:percentage="Number(Math.round(smAreaVo.diskSizeUsage / smAreaVo.diskSize * 10000)/100.00)"
							 color="#2675c5">
						</el-progress>
						 <span class="base_line">{{smAreaVo.diskSize}}GB</span>
					  </el-col>
					</el-row>
				</div>
				
				<div class="base_item">
					<el-row>
					  <el-col :span="4">
					  	<span class="base_title"></span><span class="base_title">CPU大小</span>
					  </el-col>
					   <el-col :span="20">
					  	<el-progress 
							:text-inside="true" 
							:stroke-width="18" 
							:percentage="Number(Math.round(smAreaVo.cpuUsage / smAreaVo.cpuNum * 10000)/100.00)"
							show-text
							 color="#2675c5">
						</el-progress>
						 <span class="base_line">{{smAreaVo.cpuNum}}核</span>
					  </el-col>
					</el-row>
				</div>
  			</div>
        
        	<div class="run_detail">
        		<p class="title">运行情况</p>
        		<div class="run_detail_item" v-for="item in 2">
        			<p class="run_detail_p_title">Docker1</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">CPU:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">内存:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">服务类型:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><el-button type="primary" @click="doKuoRong" plain>资源扩容</el-button></p>
        			<p class="run_detail_p"><el-button type="warning" plain>生成副本</el-button></p>
        			<!--<p class="run_detail_p"><el-button type="danger" plain>重启</el-button></p>-->
        		</div>
        		<div class="run_detail_item run_detail_item_danage" v-for="item in 2">
        			<p class="run_detail_p_title">Docker1</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">CPU:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">内存:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><span class="run_detail_span_title">服务类型:</span>4核 剩余10%</p>
        			<p class="run_detail_p"><el-button type="primary" plain>资源扩容</el-button></p>
        			<!--<p class="run_detail_p"><el-button type="warning" plain>生成副本</el-button></p>-->
        			<p class="run_detail_p"><el-button type="danger" @click="doRestart" plain>重启</el-button></p>
        			<img class="danage_img" src="../../../../images/unset.png"/>
        		</div>
        	</div>
        	
        	
    <el-dialog
      title="资源扩容"
      :visible.sync="dialogVisible1"
      width="380px"
   
      :append-to-body="true"
   	 >
	   <el-form ref="form" :model="form" label-width="110px">
		   	<el-form-item label="CPU剩余4核" required>
		    	扩容&nbsp;
		    	<el-input 
		    		style="width: 120px;"
		    		v-model="form.cpu">
		    	</el-input>&nbsp;核
		  	</el-form-item>
		   	
		   	<el-form-item label="内存剩余8G" required>
		    	扩容&nbsp;<el-input 
		    		style="width: 120px;"
		    		v-model="form.memory"
		    		></el-input>&nbsp;G
		  	</el-form-item>
		  	<p style="text-align: center;">
		  		   <el-button>取消</el-button>
  					<el-button type="primary">确定</el-button>
		  	</p>
	   </el-form>
    </el-dialog>
    
    
    
    </section>
</template>

<script>
    
    export default {
    	props:{
    		dockerDetail:{
    			type:Object,
    			default:function () {
    				return {};
    			}
    		},
    		areaInfo:Object
    	},
        data() {
          return {
          		dwawd:'wdw',
          		dialogVisible1:false,
          		dialogVisible2:false,
          		form:{
	        		cpu:'',
	        		memory:'',
        		},
        		smAreaVo:{
        			name:'',
        			segmentName:"",
        			nodeSn:"",
        			status:'',
        		},
        		
          };
        },
        methods: {

        	doKuoRong(){
        		this.dialogVisible1 =true;
        	},
        	doRestart(){
        		    
				        this.$confirm('确认重启？重启过程中所有服务都会停止', '确认重启', {
				          confirmButtonText: '确定',
				          cancelButtonText: '取消',
				          type: 'warning'
				        }).then(() => {
				          this.$message({
				            type: 'success',
				            message: '成功!'
				          });
				        }).catch(() => {
				          this.$message({
				            type: 'info',
				            message: '已取消'
				          });          
				        });
        	}
        },
        mounted(){
        	this.smAreaVo = this.dockerDetail;
        	this.smAreaVo.segmentName=this.areaInfo.name;
        	
        },
        watch:{
        	dockerDetail:{
        		handler(newVal, oldVal){
        			this.smAreaVo = this.dockerDetail;
        			this.smAreaVo.segmentName=this.areaInfo.name;
        		},
        		deep:true
        	}
        }
  };
</script>

<style scoped="scoped">
	img.danage_img {
	    position: absolute;
	    top: 0;
	    left: 0;
	    width: 60px;
	}
	.run_detail_item_danage{
		position: relative;
		 border: solid 2px #af2626ab !important;
	}
	p.run_detail_p{
		margin: 5px 0;
	}
	p.run_detail_p_title {
    margin: 10px 0;
    font-size: 16px;
    color: rgb(38, 117, 197);
}
	.run_detail {
	    padding-top: 10px;
	    border-top: solid 2px #E6E6E6;
	}
    .smartResourceManageDetail{
    	  padding-right: 40px;
    }
    span.base_line{
    	    position: absolute;
	    top: 0px;
	    right: 10px;
	    font-size: 13px;
    }
    .base_item {
	    margin: 15px 0;
	}
	p.title {
	    font-size: 20px;
	    font-weight: 600;
	}
	.base_title{
	    color: #6d6c6cb3;
	    font-size: 13px;
    	font-weight: 600;
	}
	.run_detail_item {
	display: inline-block;
    width: 200px;
    height: 217px;
    border: solid 1px #E0E4E7;
    border-radius: 6px;
    text-align: center;
    margin:15px;
	}
</style>